import {createApp} from 'vue'
import {createPinia} from 'pinia'
import {createPersistedState} from 'pinia-plugin-persistedstate'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import ElementPlus from 'element-plus'
import App from './App.vue'
import '@/assets/style/index.scss'
import '@/assets/style/common.scss'
import '@/assets/iconfont/iconfont.scss'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import '@/assets/style/element-dark.scss'
import '@/assets/style/element.scss'
import defineDirective from '@/directive'
import router from './router'
import '@/permission'
import {storeParse, storeStringify} from '@/utils/tools.ts'
import BaseTable from '@/components/BaseTable/index.vue'
import BaseIcon from '@/components/BaseIcon/index.vue'
import BaseForm from '@/components/BaseForm/index.vue'
import BaseSearch from '@/components/BaseSearch/index.vue'

const pinia = createPinia()
pinia.use(createPersistedState({
	serializer: {
		deserialize: storeParse,
		serialize: storeStringify
	}
}))
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
	app.component(key, component)
}
defineDirective(app)

app.component('BaseTable', BaseTable)
app.component('BaseIcon', BaseIcon)
app.component('BaseSearch', BaseSearch)
app.component('BaseForm', BaseForm)
app.use(pinia).use(ElementPlus).use(router).mount('#app')
